package com.yanqu.road.server.cmd.activity.huashigang;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.huashigang.HuaShiGangProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.huashigang.HuaShiGangMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_HUA_SHI_GANG_ATTACKED_ELITE_LIST, desc = "花石纲有人打过的精英怪列表")
public class GetAttackedEliteListCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = HuaShiGangMgr.getActivityInfo();
        if (!ActivityMgr.activityInShowTime(activityInfo)) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        HuaShiGangProto.CrossGetHuaShiGangEliteListReqMsg.Builder builder = HuaShiGangProto.CrossGetHuaShiGangEliteListReqMsg.newBuilder();
        builder.setActivityId(activityInfo.getActivityId());
        player.sendPacket(CrossProtocol.C2_HUA_SHI_GANG_ATTACKED_ELITE_LIST, builder);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            HuaShiGangProto.GetHuaShiGangEliteListRespMsg.Builder builder = HuaShiGangProto.GetHuaShiGangEliteListRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_HUA_SHI_GANG_ATTACKED_ELITE_LIST, builder);
        }
    }
}
